﻿CREATE function fn__bits(
	@N int
)RETURNS @T TABLE(Bit int, Value bit)
AS
BEGIN
DECLARE @Text varchar(512) SET @Text = ''
DECLARE @i bigint SET @i = 0
WHILE @i <= 15 BEGIN
	INSERT INTO @T VALUES(@i+1,@N & POWER(2,@i))
	SET @i = @i + 1
END
RETURN
END

